Re-solved problem 5