Updated Refactored Code