The old cosergate code... for historical purpose