Refactored changeDir