Replaced code with switch-case