Optimization of the 2nd solution