Optimize solution.