Instead of using all of those else if statements, could you try using nested switch statements?