Change current working directory determination logic