TernarySpaces - remove ugly loop