Re-factor switch statements