Re-solved problem 1