this is the same code as in the _overwriteTimeout function