adjusted to upstream changes