I now submit a version which uses function pointers