fix loading tasks race condition