refactoring Astar