Re-solved problem 6