Optimize send() function to be created only once