Couldn't you have used the transaction's keys collection instead?