Implements reset function