complete refactor of TSP algo code