[refactor] reorganize code.