updated to remove if condition

use switch case instead if its allowed.