add to_map_in, improve to_map_to and test