finished the replace function. Need to test