added verification that cwd exists