added database wait support