bug fix with chdir