Fixed typo, added extra checks for bson functions