completed problem 8, might want to reread code and clean it up.