added some enhancements to the demo to make it a little smarter about being smart