Improved the algo.
Version 1.0.2