db is a global object