persist messages to mongo db. a little messy on both sides, will refactor