Problem 9 works properly now