fixed to handle null values without error