adding MaxDepth support