removed unused graphData array, more importantly fixed sum < p issue, in which p = 0 and the loop never executes