more clever way to wait mysql