fix bugs, added matrix demo