Reorg, added format function (not tested)