added a file sending algorithm