Added method2 for max path