longest path dynamically