Update Z Algorithm