start factoring out the blob of code into testable objects