added comments and a reset function