moved chdir to init function, simplified init call