Fixed 'query is not defined' error.