Replace depecreated has_key() function with key in dict idiom