added anticipation algorithm