Fixed break in optimization. Max needs to be included.