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

It makes code more compact.