merge old change from 2.2 branch to give legend in heading