works up to i = 22, elements incorrectly set outside of first block