db must be explicitly passed