refactor output file name generation