Imitation of the example code. Not tested yet.