Fixed looping

Array numbering was wrong. Fixes #2