first pass solution for problem 8