Better constraint handling
reference implementation