Check data.query

Hi, sometimes data.query is undefined, and data.query.results do an uncaught typeerror, that not good. I add check.