[NOISSUE] fix some trivial bug and codes rearrange