rewrote solver and constraints equations