slight refactoring of collection writer
removed need for Work.Close, use defer instead