working out the second part of problem