added invert_mask