`dir` should be an argument so you are not relying on the external state.