changed if-elseif to switch