Contributed by Vishwajeet Dusane. (cherry picked from commit ef9dc6c44c686e836bb25e31ff355cff80572d23)