Adding a function in constraint doesn't work