Please consider moving up lines 77 to 100 into own function.