Some of the worst code I ever wrote. Functional though.