Changed structure of Wait for detect

Changed the structure of the if statement for half a second, untested.