fixed some bugs and added sample 0004