cleaned up encoding example