final version - logging enabled