updated with fixes to encoding 1