modify add_last_line method