added terminal value calc
fixed conflicts