Bound the variable BaseDepth out of case...if expression 

I think it's a more concise way.