Added has_key check