Fix replace behavior