Fix number_sold algorithm