revised work with switch statement instead of if else statements