copied from AAAI version of the paper