Refactored Code v1