moved logging around