check that res has not already been sent before sending catch 500