it strikes me that some of this duplication can be DRYed up somehow