partially complete moment-masking algorithm