Extract private #modify_keys method