parallelize encode and decode