Enhance wait function