Fixed up encode