Improving a silly way to make a query