factored out identical commented logging code