added finish encoding