Moved some template logic to View