Check for nil before storing object in dictionary