add demo.m and fix bugs