replaced if with switch statement