updated cd to validate the path before setting the wd