Working program, needs some cleaning up