tweaked refactoring of brain