Changed waiting bool to volatile