detect the dir