replaced payload variable with scope variable