make use of each_slice and flattened arrays