pathfind optimal new map, and some usefull code