Wrote a replace function