sample: refactored+enhanced