Moved reversing logic into astar lib