Changed if statements  switch-case construction