fixed stack distance problem!!!!
fix stack distance with O(n), not bad :-?