Adding solutiont to problem 30