before_send: fix logic