Implemented function for prediction