first version of efficient solver