fixed a couple of bugs in example, improved output