Minimum refactor to encapsulate code into methods.