Refactored Code.