correction to calculate_profit_loss