small reorg of functions