changed series of if statements to if else