fixed bug with constraints