modified to use compare_exchange_weak;
altered load memory ordering to memory_order_consume