fix strange idea rearrange code