adjust the function postion

make sure the code struction is more clear.