Array indices go from 0 to array_size, but not including it. Your for loop tries to access your_array[your_array_size] because the loop condition is wrong. Can you see how to fix it?
(And please replace every instance of 15 in your code with LIMIT, because that's what its for.)