fixed the prediction function