Refactor the log