Refactored example code