Why are you incrementing S? (2nd last line)