support both grammar and smart queries
divided event handlers from functions