Move logic out of table view controller