updated db querying