Added the ability to apply N optimally and visualize the results