This is a new function that handles reseting the worker when needed.