add beforeStart and afterStart functions