created a reset function and added some comments