Use Dir.chdir instead of system(cd)