implemented rewrite_elem_src