updated database querying