some revision/preparation for final algorithm.