minor adjustments and refactoring