Wait and Scan in Subs and Functions