finished prediction code