Fix the depth checking