checking for nil instead of null