Add the triggers and function