optimized jewels-encoder