pull header and cleanup logic into method