bloody nested if statements to sensible methods