refactoring of RecalculateFileSize function