refactoring model layer