Move code out of the view controller