refactored switch and list