This is what I have intended to do. But adding a list to my code seems to break it. Just slowly implementing this, I haven't added the code to add stations into the list, just pass the list around:
route(X,Z):-
V = [],
getroute(X,Z,V).
getroute(X,Z,V) :-...