reorganized solver main