replace the infrquent in place