Added option to optimize