to write the ending