probably shouldn't use the same counter variable both times...