implemented Astar pathfinding