some slight refactoring