public StringBuilder sub(StringBuilder aValue, String MaxForSub) {

        while (aValue.length() > MaxForSub.length()) {
//fills up 0's if value got more numbers

            MaxForSub = "0" + MaxForSub;
        }

        for (int i = aValue.length(); i >= 1; i--) {

            if (MaxForSub.charAt(i - 1) > aValue.charAt(i - 1)) {

                tmp = i - 1;
                while (aValue.charAt(tmp - 1) == '0') {

                    aValue.setCharAt(tmp - 1, '9');
                    tmp--;

                    if (tmp == 0) {
                        break;
                    }
                    if (aValue.charAt(tmp - 1) != '0') {
                        tmp1 = aValue.charAt(tmp - 1);
                        aValue.setCharAt(tmp - 1, convertAndSubtrac1(tmp1));
                        minuend = aValue.charAt(i - 1);
                        subtrahend = MaxForSub.charAt(i - 1);
                        aValue.setCharAt(i - 1, convertAndSubtrac10(minuend, subtrahend));
                        break;

                    }
                }
            } else {

                minuend = aValue.charAt(i - 1);
                subtrahend = MaxForSub.charAt(i - 1);
                aValue.setCharAt(i - 1, convertAndSubtrac(minuend, subtrahend));

            }

        }

        if (aValue.charAt(0) == '0') {
            aValue.deleteCharAt(0);
        }
        aValue.setCharAt(aValue.length() - 1, convertAndSubtrac1(aValue.charAt(aValue.length() - 1)));
        return aValue;
    }