Added option to specify wait time