Refactored filename generation