Change calculation algorithm