bugfix for task race condition