trying to optimize encoding