work in progress, refactoring