break code up into class methods and write a test