proper check for whether res.send is valid