refactored models.js with class prototype style