a few changes & add reset function