more example and better code
update since Hohhot

better code and less bug(I hope)