Add an wait function