working on total variation function