Updated analysis functions and overall process to be more succinct and close mongoDB instances