refactoring, started to implement logging