Refactor: Reordered code in edit_map.cpp