fixed null pointerd on encoding occurring when calling second constructor