Fix array out of bounds in updateHeatmap