filestream refactoring