Changed to new encoder function