Update model.js

minor refactoring