Fix: define new ref before trigger