added loop counter variables