this works but is very slow.
minor things.
TODO is not applicable as this class is trying to print lexicographically.