fixed chdir bugs