modified and added demo code