rearranged scope of certain variables