Refactor to use bson.M, utility function