refactored code into modelClass.js