truncate ref if too long