updated replace_in_repo function