refactor mongodbUtil.js