Fix solution for problem 6