Changed mongoose.Type to mongoose.Types in the following user function