replace if with a switch statement

Change-Id: I2eccb3606b42cc567f600c10e47f6aafebbabb46