switch toolstate refactoring