Add check for valid encodings