Fix directory depth check