Fixed handling of null values