fixed the encode issue