Updated to use switch case.