Solving equations by catching method