added switch statement instead of if else statements in the buttonHandler function