public static boolean isAnagram1(String text1, String text2) {
        if (text1 == null || text2 == null) return false;
        if (text1.isEmpty() || text2.isEmpty()) return false;

        String text1Lower = text1.toLowerCase();
        String text2Lower = text2.toLowerCase();

        String text1WithoutSpaces = text1Lower.replaceAll(" ", "");
        String text2WithoutSpaces = text2Lower.replaceAll(" ", "");

        if (text1WithoutSpaces.length() != text2WithoutSpaces.length()) return false;

        Map<Character, Integer> map1 = addToMap(text1);
        Map<Character, Integer> map2 = addToMap(text2);

        for (Character character : map1.keySet()) {
            if (!map1.get(character).equals(map2.get(character))) {
                return false;
            }
        }

        return true;

    }