Max/Gary - minor restructuring of code as a pairing exercise.