Minor:

- cleanup and convert
I would done something like this:
http://pastebin.com/cuj5Cu0k