cherry pick PR588 to master