removed a bug that appeared when a idx == -1
shoud not usually happen, only in bad setup.