changes to encoder code