Refactoring Automatas