fix broken transaction logic if executing a query