added scope guards for transactions