scan: use var for match to avoid invalidating it befroe later access