error handling in predict method