refactoring enigma stuff