Update with refactoring - still not finished!