the thieves , finding the body gone , realize that yet another person must know their secret , and set out to track him down . one of the thieves goes down to the town and comes across baba mustafa , who mentions that he has just sewn a dead man 's body back together . realizing that the dead man must have been the thieves ' victim , the thief asks baba mustafa to lead the way to the house where the deed was performed . the tailor is blindfolded again , and in this state he is able to retrace his steps and find the house . the thief marks the door with a symbol . the plan is for the other thieves to come back that night and kill everyone in the house . however , the thief has been seen by morgiana and she , loyal to her master , foils his plan by marking all the houses in the neighborhood with a similar marking . when the 40 thieves return that night , they can not identify the correct house and the head thief kills the lesser thief . the next day , another thief revisits baba mustafa and tries again , only this time , a chunk is chipped out of the stone step at ali baba 's front door . again morgiana foils the plan by making similar chips in all the other doorsteps . the second thief is killed for his stupidity as well . at last , the head thief goes and looks for himself . this time , he memorizes every detail he can of the exterior of ali baba 's house . the chief of the thieves pretends to be an oil merchant in need of ali baba 's hospitality , bringing with him forty thieves hiding in oil jarsmules loaded with thirty - eight oil jars , one filled with oil , the other thirty - seven hiding the other remaining thieves . once ali baba is asleep , the thieves plan to kill him . again , morgiana discovers and foils the plan , killing the thirty - seven thieves in their oil jars by pouring boiling oil on them . when their leader comes to rouse his men , he discovers that they are dead , and escapes . to exact revenge , after some time the thief establishes himself as a merchant , befriends ali baba 's son ( who is now in charge of the late cassim 's business ) , and is invited to dinner at ali baba 's house . the thief is recognized by morgiana , who performs a dance with a dagger for the diners and plunges it into the heart of the thief when he is off his guard . ali baba is at first angry with morgiana , but when he finds out the thief tried to kill him , he gives morgiana her freedom and marries her to his son . ali baba is then left as the only one knowing the secret of the treasure in the cave and how to access it . thus , the story ends happily for everyone except the forty thieves and cassim . 
foils the thieves ' plan .
how does morgiana help ali baba ?
how does morgiana help ali baba ?