Adding functionality to track longestPath