Converting to a switch statement and declaring variables.