db is now a function