REV Rearranged some code