move some lock operation to print functions
merge to master