Fix a bug in depth query