Properly limiting the for loop makes it much faster