corrected dijkstra subroutine.
Now it considers only the visited tile to make the path.