adding master path finding function