Changed chain of if else statements to use switch instead