Move logic to model
Improve coding style
Merge pull request #1 from cnosuke/refactoring/move_logic_to_model

Move logic to model