refactoring constraint handling