moved path parse out of while loop to fix run once bug