astar somewhat more functional