added null check on send property of res