replace write() with send()