Yes the problem is to do the wait at the beginning of the function before calling the video_switch command.