changed $i to 0