more refactoring in views, models and controller