Fixes #1 cannot loop

This cause is by array index is out of bounds.