added a resetState function