added code to find start and finish nodes