all code ported (no output yet ...)