Replaced compare_exchange with a simple exchage