move some lock operation to print functions