Completely new version of the solver logic