Implementing constraint solver