changed the termination criteria in astar