rework script to fit to 'ref-updated' hook