fixed replicate issues, encode2 vs encode3