fixed bug in reset function