Optimize the solution