Rearranges variables