collapse horizontally and refactoring