Improved optimization

I will test it, thanks.