replaced solve with lm to avoid fatal errors