added exceptions to wait routine