Ported the reset() function