Revert "code rearrange"

This reverts commit 84f176fe75321a8b541b0dfd1775f39ca4ec75c9.