improve code of the example