add constrain function