Modified the method for creating constraints.