Change sleep to wait.