replacing ~ with ^