fixed output_name function