fold in (optimized) ranges