refactored the demo, added more docs