need to add error handling for solve