Added model logic to view