integrate challenge generation with encoder