fixed some indexing issues