Refactor for better transaction flow