refactored the views, moved the logic into appropriate models