refactored scatter example