Refactor transactions