fix get empty encoding, need to be refactored further