depth function

Depth calculation