I put the createlock back into the loop because it seems not possible to reuse same lock for different requests.