changed names of variables
refactored switch