changed two variables from scope to controller variables