changed way of detecting working directory