fixed transactions and small code simplification