refactor some really brain dead code duplication