Improve optmization pipeline