tweaked demo code