Re-solved problem 3