Fixed change_directory to change back to old directory if error occured