fixed bug in setting working directory and code cleanup