Don't use Dir.chdir.
Use multitask.