correct some function orders to make the script more correct according to our system