algorithm thought