reorganize code