Broke the code up into logical pieces.