Null check on query