another attempt at handling encodings