got problem one working, needs lots of comments and cleaning up