added detect method to wait.rb