improved the detection of the working directory