Added the ability to use an index array