complete question 12, though it's slow an inefficient.