[BUGFIX] Handle null values correctly to avoid PHP errors