update code for 2 level template edit