fixed improper indexing