work in progress and refactoring