Updated promise return for waitFor function and removed usage of Q