changed begin_element to final_elemnt