put mode logic and filename reporting into resource so everybody can benefit