Correctly querying db.