Broke up big method into smaller methods to make this code easier to work with.