replaced if/elseif with switch