adding better logging and log formatting