put nid in filenames, fix logic omission