Finally finished Problem 12