use only inordermap, much conciser code