fixing wait code errors