updating V algorithm