fixed predict algorithm