guarding against writing null values