Refactored implementation code (following rule of 3)