Convert to switch
Minor fixes
Variable name changes