Added a separate listening thread