generalize to work with arbitrary refactoring hooks