minor refactoring with @gabegaster