update animation algorithm