Refactoring

divide controller into model