rearrange function and vars