#vulnerable code 
                                private Map<String, Keyword> checkNextKeyword(long tagId, KeywordExtractedItem keywordOccurrence, Map<Long, Map<Long, CoOccurrenceItem>> coOccurrences, Map<Long, KeywordExtractedItem> keywords) {
        Map<String, Keyword> results = new HashMap<>();
        if (!coOccurrences.containsKey(tagId))
            return results;

        Map<Integer, Set<Long>> mapStartId = createThisMapping(coOccurrences.get(tagId), tagId);
        Set<Long> coOccurrence = mapStartId.get(keywordOccurrence.startPosition);
        if (coOccurrence == null) {
            return results;
        }

        Iterator<Long> iterator = coOccurrence.stream()
                .filter((ccEntry) -> ccEntry != tagId)
                .filter((ccEntry) -> keywords.containsKey(ccEntry)).iterator();

        while (iterator.hasNext()) {
            Long ccEntry = iterator.next();
            String relValue = keywords.get(ccEntry).getValue();
            //System.out.println("checkNextKeyword >> " + relValue);
            //if (!useDependencies || keywordOccurrence.getRelatedTags().contains(relValue.split("_")[0])) {
            List<String> merged = new ArrayList<>(keywords.get(tagId).getRelatedTags()); // new
            merged.retainAll(keywordOccurrence.getRelatedTags()); // new
            //System.out.println("    related tag = " + idToValue.get(ccEntry) + ", related tags = " + keywords.get(tagId).getRelatedTags().stream().collect(Collectors.joining(", ")));
            //System.out.println("      merged = " + merged.stream().collect(Collectors.joining(", ")));
            if (!useDependencies || keywordOccurrence.getRelatedTags().contains(relValue.split("_")[0]) || merged.size()>0) { // new
                //System.out.println("checkNextKeyword >>> " + relValue);
                addToResults(relValue,
                        keywords.get(ccEntry).getRelevance(),
                        results, 1);
            }
        }

        return results;
    } 
                            #location 21 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                                private Map<String, Keyword> checkNextKeyword(long tagId, KeywordExtractedItem keywordOccurrence, Map<Long, Map<Long, CoOccurrenceItem>> coOccurrences, Map<Long, KeywordExtractedItem> keywords) {
        Map<String, Keyword> results = new HashMap<>();
        if (!coOccurrences.containsKey(tagId))
            return results;

        Map<Integer, Set<Long>> mapStartId = createThisMapping(coOccurrences.get(tagId), tagId);
        Set<Long> coOccurrence = mapStartId.get(keywordOccurrence.startPosition);
        if (coOccurrence == null) {
            return results;
        }

        Iterator<Long> iterator = coOccurrence.stream()
                .filter((ccEntry) -> ccEntry != tagId)
                .filter((ccEntry) -> keywords.containsKey(ccEntry)).iterator();

        while (iterator.hasNext()) {
            Long ccEntry = iterator.next();
            String relValue = keywords.get(ccEntry).getValue();
            //System.out.println("checkNextKeyword >> " + relValue);
            //if (!useDependencies || keywordOccurrence.getRelatedTags().contains(relValue.split("_")[0])) {
            List<String> merged = new ArrayList<>(keywords.get(ccEntry).getRelatedTags()); // new
            merged.retainAll(keywordOccurrence.getRelatedTags()); // new
            //System.out.println("    co-occurring tag = " + idToValue.get(ccEntry) + ", related tags = " + keywords.get(ccEntry).getRelatedTags().stream().collect(Collectors.joining(", ")));
            //System.out.println("      merged = " + merged.stream().collect(Collectors.joining(", ")));
            if (!useDependencies || keywordOccurrence.getRelatedTags().contains(relValue.split("_")[0]) || merged.size()>0) { // new
                //System.out.println("checkNextKeyword >>> " + relValue);
                addToResults(relValue,
                        keywords.get(ccEntry).getRelevance(),
                        results, 1);
            }
        }

        return results;
    }