why is it needed to loop for restoring the error handler here ? I think it deserves a command explaining it