refactor models, controllers