add closecourse function and fixed some bug