Refactor log