remove unneeded conditional nesting in transaction middleware