Added null check for response in Query