A* search used for finding the optimal path