improve encoder