Changed to switch case instead of if statement