some bugs in the constraint fixed