refactored SYAlgo with simple rules.