Problem 3

Could be more efficient.