modified main logic, reset method introduced