refactoring code base on the new model