Changed switch statements to if statements