backporting some change to avoid merge conflict with main branch