refactored example