fixed some indexing problems