Now added wait interval as a parameter