cleanup and changed from has_key to "in" for performance