def METHOD_NAME(word_counts, start_para):
    # find the end_para that fills up our passage
    end_para = start_para+1
    while end_para < len(word_counts) and sum(word_counts[start_para:end_para]) < opts.max_passage_words:
        end_para += 1
    if sum(word_counts[start_para:end_para]) > opts.max_passage_words and sum(word_counts[start_para:end_para-1]) >= opts.min_passage_words:
        # don't need the last paragraph
        end_para -= 1
    if end_para == len(paragraphs):
        # include some earlier paragraphs
        while start_para > 0 and sum(word_counts[start_para:end_para]) < opts.min_passage_words:
            start_para -= 1
    return start_para, end_para