fixed predict function