Refactored code.