Break out demo code to separate core functionality