backport @matael commit