Changed to use write() instead of send()