reworked some indexing. something is still wrong.