reorg the code