attempt at encode speedup, gained about 15%