make _db a function