Fix bug that did not fill correct index