remove global "i" var + cache arg length