updated chdir functionality