Fix overall depth calculation
Implement filter with reverse and reduce in functional