Move triggering code into own function