improve algorithm for updating WFs