add beforeSend function