Refactored Code and Example