refactor solver