setMinMaxDepth function added to prevent negative depth issue