adding task wait logic