fixed indexing error in computeD