Added check to make sure the folder actually exists