transaction loop