Refactor code to use logger class.