replace direct reference to elem_m and next_m with get_elem() and get_next()