added support for logging
restructuring