correcting depth logic