Reorganize code between models, view and controller