refactor saving of prediction data into another method