fix bug with end of teaching