Move invert_dict based on @ElDeveloper's excellent comment