separated function for create_filename