Fix code for case if cwd is undefined