Fixed leaked for loop i

Ref issue #21