fixed silly analyzer for 0 based indexing error, made costs quadratic