Moved validatePath function from main to mainFunc