Adding replace_contents method to replace