Updated begin and end transaction methods
Refactored code