SS code should use val instead of var in for loops