Reset Function not working properly