thinking in first algorithm