fix bug in calculate profit method