tidied comments and logging