refactored code two