extracted query to method