Refactor astar