refactored prediction