refactored code.