Move code to view class.