slightly more refactoring