Moved code to view and less variables