Fix error in if statement not using directory location