initial working version, no tests

refactoring