setting scope variable correctly