refactor hslice to optimize collapse
collapse: performance optimizations