a bit more refactoring