call commit only when in transaction