move some code
correct message logging