predict functions refactored