updated indexing put

indexOf would always return >-1, so now it checks the index vs count and -1.