breaking into smaller methods to hopefully make more understandable.