Made the example work
and a little bit more sophisticated