finished implementation of the constraints solving