get it into a class and test it with at test
some cleanup