private long getPosition(int length){
        long bestPos = 0;
        int bestLeng = 0;
        for (Long pos : freePointers.keySet()){
            int leng = freePointers.get(pos);
            if (length <= leng){
                if (bestLeng == 0 || bestLeng > leng){
                    bestLeng = leng;
                    bestPos = pos;
                }
            }
        }
        if (bestPos == 0)
            bestPos = dataStorage.length();
        return bestPos;
    }