optimize the dir path