replaced sleep with waitforcompletion param