refactoring
working switch