Optimize flat_pmap to iterate once instead of twice