change keys.each to each_key in Connection