I'm not too sure whether you understood the code properly,
Sleep (10000)
The reason why the sleep code is there is too allow the top code to do its job if takes more than10 seconds then its timed out , the code move to the next stage, this is where I thought maybe I mixed it up or missed...