update code for mongoose 3.6.8