public static BMap fromBencodedValue(String bencodedValue, AtomicInteger index) throws BParsingException {
        if (!bencodedValue.startsWith(String.valueOf(START_SYMBOL), index.get())) {
            throw new BParsingException("Invalid bencoded map");
        }
        index.incrementAndGet();
        List<BString> keys = new ArrayList<>();
        BMap toReturn = new BMap();
        for (; index.get() < bencodedValue.length(); index.incrementAndGet()) {
            char currentCharacter = bencodedValue.charAt(index.get());
            if (currentCharacter == END_SYMBOL) {
                break;
            }
            BString key = BString.fromBencodedValue(bencodedValue, index);
            index.incrementAndGet();
            IBValue value = BParser.fromBencodedValue(bencodedValue, index);
            if (keys.size() > 0) {
                if (keys.get(keys.size() - 1).compareTo(key) > 0) {
                    throw new InvalidSortingInBMap();
                }
            }
            keys.add(key);
            toReturn.put(key, value);
        }

        if (index.get() >= bencodedValue.length()) {
            throw new BParsingException("No ending character");
        }
        return toReturn;
    }