fix pick function to preserve key order