Rearranged and refactored some variables