Added stop token handling