Adding depth logic