sendfiles: refactoring