Moves UTF8 decoding to separate function