Was checking if query was valid not if it was empty