equation solver refactoring