Group if statements to switch statement. Group the dublicate code lines.