Refactoring switches for better code quality