Fixed indexing issue between versions. Will be reimplementing for GPU version