refactoring the code, better tracking of when a new file transfer begins