refactored the demo