Changing directory must happen last