[xin] reorganize code structure