working to handle success and failure of writing to db, unique indexes have been added to mongo tables