more elegant handling of null values from postgres