working on the new path algorithm