tidy up formatting and logging