final working demo code