Refactored code + reordered methods