Initial working for replace ref
Merging changes