Rebuild the code using solve function