Small refactoring in commit()
Implemented retry and rollback mechanism