improved query db