add a demo and fix some bugs