the latest working demo code from Andres. Removed old code.