code refactoring, preparing for solver