generate query from user input