refactored model.js