Using index in each() instead of counter