adding changes to support keyEncoding