move each_slice logic out of controller