Rearranging subs and loops