you could write here ```e->setValue(j)``` and save the mat_id variable and the assignment later on.