Imporved the logging