Fixes indexing errors