get_filename helper function