check if the dir exists before returning