generalised backsub_both_sides