Amended code to match text
Corrected typo
Adapted code to current version of Database.MongoDB