Refactored code to include an Objective class