porting replace sample