added null check to db, won't try to access a null object.