cleanup: priority_effect as a parameter instead of a global variable