Fixes faulty index in certain situations