added checking of res.finished