Added Optimize functionality