Replace deprecated contains with has_key.