extract utils methods, fix decoding issues