extends detecting maxdepth