Sped up Problem 3