refactor spaceElimination