more refactor
simplify 'return to reset' logic
combine first/nth processing in file loop