updated filename logic, separated from print step