Bug fix in chdir