Rearranging code with macros