debug, and this is may be the perfect version so far. after this, i will
start to measure these algorithms.