Fixed not checking for null in cursor