changed maxdepth check to greater and equal