fixed a-star search terminating bug