cleaned up encoding