more internal refactoring