changing wait function