Though it may be slightly different, this other program of mine, though it didn't work fully on the toStirng(), might help.
...