replaced if else logic with switch case logic