added mongo db, flipped the code to work sequentially