changing has_key function