Remove lots of if statements