optimized encoding