Corrected trigger function