Added maxDepth option