some initial refactoring