create a waitsFor function to async wait instead of time.sleep