implemented prediction function