could key1 and key2 be called outer_key and inner_key? (This also could be applied to other places in the code)