updated logging and saving to mongo