Added accidentally removed "val i = 0" back.