Converted an if block to switch