Factorize toTabs and toSpaces