fixing potential null db error