updated example

I moved one part of the example to the main method to have all samples
at the same place