Working on wait function.