fix bug in Replace
add Diversification process