moved chdir to generate method