def refined_book(book_id='all'):
    if book_id == '1' or book_id == '2' or book_id == '3' or book_id == '4':
        query = db.processed_text.find_one(
            {'book_id': book_id})  #query if data present against the book_id
        if query:  #if something come in the response
            if query["words"]:  # if the response contains words
                words_json = query[
                    "words"]  #load the json of words in the word_json variable
                return words_json  #return the word_json which has the words
            else:  # if there is a document present but there is a no value against query["words"]
                data = Task1.show_the_list_of_stop_words(
                    book_id
                )  #trigger the function of to get the refined text without stop words
                updateQueryTask1(
                    book_id, data
                )  #as the document present so just update the value against the book id words
                return json.dumps(data)  #return the json words json
        else:  #if the query is empty no document is present relative to the book id
            words_are = Task1.show_the_list_of_stop_words(
                book_id
            )  #trigger the function in the task1 to get the refind words
            insertQueryTask1(book_id,
                             words_are)  #inset the document in the database
            return json.dumps(words_are)  #return the json of words
    elif book_id == 'ALL' or book_id == 'all':
        my_dict = {
        }  #create the dictionary that will contain sum of all the other dictionaries against book id
        list_of_all_books = ['1', '2', '3', '4']  #list of all books ids
        for book_no in list_of_all_books:  #one by one iterating each book
            query = db.processed_text.find_one(
                {'book_id':
                 book_no})  #querying if data present against that book id
            if query:  #if some document is present against the book id
                if query[
                        "words"]:  # checking if the cotains any value against words key
                    words_dict = json.loads(
                        query["words"]
                    )  #load converting that word json into dictionary
                else:  # if document is present but there is value against words key
                    words_dict = Task1.show_the_list_of_stop_words(
                        book_no
                    )  # triggering function in task1 file to get words dictionary
                    updateQueryTask1(
                        book_no, words_dict
                    )  # as the document present so just update the value against the book id words
            else:
                words_dict = Task1.show_the_list_of_stop_words(
                    book_no
                )  ##trigger the function in the task1 to get the refind words
                insertQueryTask1(
                    book_no, words_dict)  #inset the document in the database
            my_dict[
                book_no] = words_dict  #placing the dictionaries in the main dictionary so later we can view the words against book id
        return json.dumps(
            my_dict)  #returning the json containing all the dictionaries
    return "Books only from 1 to 4"